home *** CD-ROM | disk | FTP | other *** search
- /*
- File: QDTextRun.h
-
- Contains: xxx put contents here xxx
-
- Written by: Essam Zaky
-
- Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <2> 1/4/94 EZ clean up
- <1> 1/4/94 EZ first checked in
-
- */
-
- #ifndef _QDTextRun_
- #define _QDTextRun_
-
- #ifndef _ToolBoxDump_
- #include "ToolBoxDump.h"
- #endif
-
- #ifndef _RunObject_
- #include "RunObject.h"
- #endif
-
- #ifndef _Array_
- #include "Array.h"
- #endif
-
- #ifndef _Streams_
- #include "Streams.h"
- #endif
-
- //***************************************************************************************************
-
- #ifdef txtnScal
- const ClassId kQDTextRunClassId = 'QDT+'; //scal factor are written to stream
- #else
- const ClassId kQDTextRunClassId = 'QDTx';
- #endif
-
- const AttrId kFontAttr = 'font';
- const AttrId kSizeAttr = 'size';
- const AttrId kFaceAttr = 'face';
- const AttrId kForeColorAttr = 'klor';
-
- //constants for message to UpdateAttribute
- const long kForceScriptModif = 1; //for font
- const long kAddSize = 2;
-
- const long kToggleFace = 4;
- const long kAddFace = 8;
- const long kRemoveFace = 16;
- /*a face can be added and another removed if updateMessage has both kAddFace and kRemoveFace set.
- This is only possible if CAttrObj::Update is called by attr and not by obj, since in this caller can a ptr
- to the following type:
- */
- struct TAdd_RemoveFaces {
- long face2Add;
- long face2Remove;
- };
- typedef TAdd_RemoveFaces* TAdd_RemoveFacesPtr;
- //***************************************************************************************************
-
- Fixed StdTxFixedMeas(short byteCount,const void *textAddr, Point numer, Point denom);
-
- //***************************************************************************************************
-
- class CQDTextRun : public CRunObject {
- public:
- CQDTextRun();
-
- void IQDTextRun();
- virtual CAttrObject* CreateNew() const;
-
- virtual ClassId GetClassId() const;
-
- Boolean IsTextRun() const;
-
- virtual void GetAttrIDs(short* countAttr, AttrId* attrArray) const;
-
- virtual char GetRunDir() const;
- virtual Boolean Is2Bytes() const;
- virtual char GetRunScript() const;
- virtual void SetKeyScript() const;
-
- virtual void SaveRunEnv();
- #ifdef txtnScal
- virtual void SetRunEnv(SetRunEnvPb* paramPb) const;
- #else
- virtual void SetRunEnv() const;
- #endif
-
- virtual void SetDefaults(long message = 0);
-
- virtual Boolean FilterControlChar(uchar theKey) const;
-
- virtual void DoPixel2Char(Pixel2CharPb* paramPb);
- virtual short DoChar2Pixel(Char2PixelPb* paramPb);
- virtual void DoDrawJust(DrawJustPb* paramPb);
-
- #ifdef txtnRulers
- virtual Fixed DoFullJustifPortion(FullJustPortionPb* paramPb);
- #endif
-
- virtual Fixed DoMeasure(MeasurePb* paramPb);
- virtual StyledLineBreakCode DoBreak(LineBreakPb* paramPb);
-
- virtual void SetCursor(Point, const RunPositionPB*) const; //set it to ibeam
-
- virtual OSErr WriteToStream(CStream* outputStream);
- virtual OSErr ReadFromStream(CStream* inputStream);
-
- protected:
- char fScript;
- short fFont;
- long fFace;
- RGBColor fForeColor;
-
- /*the lowest byte is reserved for the QD Style (bold, italic, ...), descendents can add more faces*/
- char fDirection;
- Boolean f2Bytes;
- short fSize;
-
- virtual long GetFaceAttrFlags(long theFace) const;
-
- virtual long GetAttrFlags(AttrId theAttr, const void* attrBuffer, long updateMessage =0) const;
- /*•note that attrBuffer may be nil, in this case descendents should return a value based only
- on the AttrId.
- */
-
- virtual void CalcHiteInfo(short* ascent, short* descent, short* leading); //override
-
- virtual Boolean EqualAttribute(AttrId theAttr, const void* valToCheck) const;
- //override, •any descendent should override, otherwise the result is always false
-
- virtual Boolean SetCommonAttribute(AttrId theAttr, const void* val2Check); //override
- virtual void AttributeToBuffer(AttrId theAttr, void* attrBuffer) const; //override
- virtual void BufferToAttribute(AttrId theAttr, const void* attrBuffer); //override
- virtual void UpdateAttribute(AttrId theAttr, const void* srcAttr, long updateMessage
- , const void* continuousAttr = nil); //override
- //continuousAttr is used only if fFlags has the kToggleFace set
-
- virtual void AddFace(long face2Add, long* destFace);
- /*normally the result is (face2Add | destFace), but this methode is the place to check for exclusif faces
- (eg superScript-subScript, condensed-extended)
- */
-
- void RemoveFace(long face2Remove, long *destFace) const;
- };
- //***************************************************************************************************
-
- #endif
-